package com.bosicloud.cmb.ibp.commom.dto;


import lombok.Data;

import java.io.Serializable;
import java.util.List;

/**
 * @param <T> 数据类型
 * @author Jack Peng / ziliang.peng@bosicloud.com
 */
@Data
public class Pagination<T> implements Serializable {

    private List<T> pageResult;

    /**
     * 页大小
     */
    private int pageSize = 10;

    /**
     * 当前页码
     */
    private int currentPage = 0;

    /**
     * 当前页号
     */
    private int currentPageIndex = 0;

    /**
     * 总页数
     */
    private int totalPageCount = 0;

    /**
     * 记录总数
     */
    private int totalRecord = 0;

    public Pagination(int currentPage, int pageSize, int totalRecord) {
        this.currentPageIndex = (currentPage - 1) * pageSize;
        this.totalPageCount = totalRecord / pageSize + (totalRecord % pageSize == 0 ? 0 : 1);
        this.totalRecord = totalRecord;
        this.currentPage = currentPage;
        this.pageSize = pageSize;
    }

    public Pagination() {
    }
}
